<template>
    <div class="list-box">
        <div class="control-box">
            <seniorMenu :formOption="listFormOption" @handleCreate="handleCreate"></seniorMenu>
        </div>
        <avue-crud :option="listTableOption" :data="tableData" ref="crud" @on-load="getList"
            @current-row-change="handleCurrentRowChange">
            <!-- 流水号 -->
            <template slot="id" slot-scope="scope">
                <span class="crud-cell-blue" @click="goDetail(scope.row)">{{ scope.row.id }}</span>
            </template>
            <template :slot="item.prop + 'Header'" slot-scope="{ column }" v-for="(item, index) in listTableOption.column">
                <div class="tableLabel">{{ column.label }}</div>
                <div v-if="item.prop == 'a'">
                    <el-input size="mini" v-if="filter && item.headerslot"></el-input>
                </div>
                <div v-else-if="item.prop == 'd'">
                    <el-input size="mini" v-if="filter && item.headerslot"></el-input>
                </div>
                <div v-else-if="filter && item.headerslot">
                    <el-input size="mini" v-if="filter && item.headerslot"></el-input>
                </div>
                <div v-else-if="filter" style="height: 28px"></div>
            </template>
            <template slot="header">
                <tableMenu :tableName="tableName" :filter.sync="filter" :pages="page" :rowIndex.sync="checkNum"
                    :listTableOption="listTableOption" :tableData="tableData" :hideList.sync="hideList"
                    @setCurrentRow="setCurrentRow" @getList="getList" @clearForm="clearForm">
                </tableMenu>
            </template>
        </avue-crud>
    </div>
</template>
  
<script>

import {
    initListoption,
    initlistFormOption
} from "@/const/crud/interfaceConfiguration/index";

import seniorMenu from "@/components/seniorMenu/index.vue"
import tableMenu from "@/components/tableMenu/index.vue"
// import { getDicts } from "@/api/system/dict/data";
export default {
    name: "Student",
    components: {
        tableMenu,
        seniorMenu
    },

    data() {
        return {
            tableName: "人事档案", //表单名称
            filter: true, //过滤器显示隐藏
            checkNum: 0, //选中行数
            hideList: [], //显示隐藏列
            loading: true,
            showSearch: true,
            subjectList: [],
            // 弹出层标题
            title: "",
            open: false,
            form: {},
            page: {
                total: 0, // 总页数
                currentPage: 1, // 当前页数
                pageSize: 10 // 每页显示多少条
            },
            searchForm: {}, // 查询条件实体
            genderSelectList: [
                {
                    label: "男",
                    value: "0"
                },
                {
                    label: "女",
                    value: "1"
                }
            ],
            gradeSelectList: [],//年级下拉数据
            tableData: [
                {
                    id: '1111',
                    a: '123',
                    b: '14512',
                    c: '453',
                    d: '345',
                    e: '123',
                    f: '345',
                    g: '345',
                }
            ],
        };
    },

    created() {
        this.getList();
    },
    mounted() {
        // this.getDicType();
    },
    computed: {
        /* 查询条件 */
        listFormOption() {
            let op = initlistFormOption(this.orgCode || "");
            return op;
        },
        /* 列表配置 */
        listTableOption() {
            let op = initListoption(this.orgCode || "");
            return op;
        },
    },
    methods: {
        getList() {
            this.loading = true;
            // getSubjectListByPage(Object.assign(
            //     {
            //         current: this.page.currentPage,
            //         size: this.page.pageSize
            //     },
            //     this.searchForm
            // )).then(response => {
            //     this.subjectList = response.records;
            //     this.page.total = response.total;
            //     this.loading = false;
            // });
        },
        //设置表格选中
        setCurrentRow() {
            this.$refs.crud.setCurrentRow(this.tableData[this.checkNum]);
        },
        //鼠标选中行数
        handleCurrentRowChange(row) {
            if (row.$index) {
                this.checkNum = row.$index;
            }
        },
        //清空按钮
        clearForm() {
            Object.keys(this.searchForm).forEach(
                (key) => {
                    if (key == 'company_id' || key == 'createUserId') { }
                    else {
                        this.searchForm[key] = ""
                    }
                }
            );
        },
        //跳转详情界面
        goDetail(row) {
            this.$emit('goDetail', { id: row.id })
        },
        //跳转新增界面
        handleCreate() {
            this.$emit('goDetail')
        },
        //高级查询
        getQuery(data) {
            for (let key in data) {
                if (data[key]) {
                    this.$set(this.searchForm, key, data[key]);
                }
            }
            this.page.currentPage = 1;
            this.getList();
        },
        //获取字典数据
        // getDicType() {
        //     getDicts('grade').then(res => {
        //         this.gradeSelectList = res.data;
        //     })
        // }
    }
};
</script>
  

<style lang="scss" scoped>
.crud-cell-blue {
    color: #409eff;
    cursor: pointer;
}

/deep/ .avue-crud__menu {
    min-height: 10px !important;
}
</style>
